/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package viewControl;

import org.hibernate.Session;

/**
 *
 * @author Oli og Anette
 */
public class AdminGUI extends javax.swing.JFrame {

    private Session session;
    private boolean rdy;
    private TrinmaalPanel tmp;
    private TeacherPanel tp;
    private ElevPanel ep;
    private PotentialPanel pp;
    private KontaktPanel kp;
    private HoldPanel hp;
    private HandleplanPanel hpp;
    private ElevLogPanel elp;

    /**
     * Creates new form SkoleGUI
     */
    public AdminGUI(Session session) {
        this.session = session;
        rdy = false;
        initComponents();

        //Indsæt TrinmaalPanel
        tmp = new TrinmaalPanel(session);
        trinmaalPanel.add(tmp);
        trinmaalPanel.validate();
        tmp.update();
        tmp.setBounds(0, 0, trinmaalPanel.getWidth(), trinmaalPanel.getHeight());

        //Indsæt TeacherPanel
        tp = new TeacherPanel(session);
        laererPanel.add(tp);
        laererPanel.validate();
        tp.update();
        tp.setBounds(0, 0, laererPanel.getWidth(), laererPanel.getHeight());

        //Indsæt ElevPanel
        ep = new ElevPanel(session);
        elevPanel.add(ep);
        elevPanel.validate();
        ep.update();
        ep.setBounds(0, 0, elevPanel.getWidth(), elevPanel.getHeight());

        //Indsæt PotentialePanel
        pp = new PotentialPanel(session);
        potkompPanel.add(pp);
        potkompPanel.validate();
        pp.update();
        pp.setBounds(0, 0, potkompPanel.getWidth(), potkompPanel.getHeight());

        //Indsæt KontaktPanel
        kp = new KontaktPanel(session);
        kontaktpersonPanel.add(kp);
        kontaktpersonPanel.validate();
        kp.update();
        kp.setBounds(0, 0, kontaktpersonPanel.getWidth(), kontaktpersonPanel.getHeight());

        //Indsæt HoldPanel
        hp = new HoldPanel(session);
        holdPanel.add(hp);
        holdPanel.validate();
        hp.update();
        hp.setBounds(0, 0, holdPanel.getWidth(), holdPanel.getHeight());

        //Indsæt HandleplanPanel
        hpp = new HandleplanPanel(session);
        handleplanOgEvalueringPanel.add(hpp);
        handleplanOgEvalueringPanel.validate();
        hpp.update();
        hpp.setBounds(0, 0, handleplanOgEvalueringPanel.getWidth(), handleplanOgEvalueringPanel.getHeight());
        
        //Indsæt ElevLogPanel
        elp = new ElevLogPanel(session);
        elevLogPanel.add(elp);
        elevLogPanel.validate();
        elp.update();
        elp.setBounds(0, 0, elevLogPanel.getWidth(), elevLogPanel.getHeight());
        setLocationRelativeTo(null);
        rdy = true;

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        tpAdmin = new javax.swing.JTabbedPane();
        elevPanel = new javax.swing.JPanel();
        elevLogPanel = new javax.swing.JPanel();
        kontaktpersonPanel = new javax.swing.JPanel();
        laererPanel = new javax.swing.JPanel();
        trinmaalPanel = new javax.swing.JPanel();
        holdPanel = new javax.swing.JPanel();
        potentialePanel = new javax.swing.JPanel();
        potkompPanel = new javax.swing.JPanel();
        handleplanOgEvalueringPanel = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Logget ind som Admin");

        tpAdmin.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                tpAdminStateChanged(evt);
            }
        });

        elevPanel.setLayout(null);
        tpAdmin.addTab("Elev", elevPanel);

        elevLogPanel.setLayout(null);
        tpAdmin.addTab("Elev log", elevLogPanel);

        kontaktpersonPanel.setLayout(null);
        tpAdmin.addTab("Kontaktperson", kontaktpersonPanel);

        laererPanel.setLayout(null);
        tpAdmin.addTab("Lærer", laererPanel);

        javax.swing.GroupLayout trinmaalPanelLayout = new javax.swing.GroupLayout(trinmaalPanel);
        trinmaalPanel.setLayout(trinmaalPanelLayout);
        trinmaalPanelLayout.setHorizontalGroup(
            trinmaalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1080, Short.MAX_VALUE)
        );
        trinmaalPanelLayout.setVerticalGroup(
            trinmaalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 675, Short.MAX_VALUE)
        );

        tpAdmin.addTab("Trinmål", trinmaalPanel);

        holdPanel.setLayout(null);
        tpAdmin.addTab("Hold og fag", holdPanel);

        potentialePanel.setLayout(null);

        javax.swing.GroupLayout potkompPanelLayout = new javax.swing.GroupLayout(potkompPanel);
        potkompPanel.setLayout(potkompPanelLayout);
        potkompPanelLayout.setHorizontalGroup(
            potkompPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 900, Short.MAX_VALUE)
        );
        potkompPanelLayout.setVerticalGroup(
            potkompPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 660, Short.MAX_VALUE)
        );

        potentialePanel.add(potkompPanel);
        potkompPanel.setBounds(0, 0, 900, 660);

        tpAdmin.addTab("Potentiale og kompetencer", potentialePanel);

        handleplanOgEvalueringPanel.setLayout(null);
        tpAdmin.addTab("Handleplan og evaluering", handleplanOgEvalueringPanel);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tpAdmin)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tpAdmin, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 703, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void tpAdminStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_tpAdminStateChanged
        if (rdy) {
            tmp.update();
            tp.update();
            ep.update();
            pp.update();
            kp.update();
            hp.update();
            hpp.update();
            elp.update();
        }
    }//GEN-LAST:event_tpAdminStateChanged
    /**
     * @param args the command line arguments
     */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JPanel elevLogPanel;
    private javax.swing.JPanel elevPanel;
    private javax.swing.JPanel handleplanOgEvalueringPanel;
    private javax.swing.JPanel holdPanel;
    private javax.swing.JPanel kontaktpersonPanel;
    private javax.swing.JPanel laererPanel;
    private javax.swing.JPanel potentialePanel;
    private javax.swing.JPanel potkompPanel;
    private javax.swing.JTabbedPane tpAdmin;
    private javax.swing.JPanel trinmaalPanel;
    // End of variables declaration//GEN-END:variables
}
